﻿using Batman.Cms.Core.Utils;
using RabbitMQ.Client;

namespace Batman.Jianbei.Forum.Areas.ChatRoom
{
    public class MQBase
    {
        protected ConnectionFactory _connectionFactory;

        protected IConnection _connection;

        protected IModel _channel;


        public MQBase()
        {
            var userName = AppSettingsUtil.DefaultInstance.Get("RabbitMq:UserName");
            var password = AppSettingsUtil.DefaultInstance.Get("RabbitMq:Password");
            var HostName = AppSettingsUtil.DefaultInstance.Get("RabbitMq:HostName");

            _connectionFactory = new ConnectionFactory
            {
                UserName = userName,
                Password = password,
                HostName = HostName
            };

            _connection = _connectionFactory.CreateConnection();

            _channel = _connection.CreateModel();
        }
    }
}
